require("should");

const { sign, verify } = require("../lib/index");

describe("test jwt sign and verify", () => {
	let symbol = Symbol("jwt");

	let obj = {
		[symbol]: {
			secretOrPrivateKey: "hopeJWT",
			secretOrPublichKey: "hopeJWT",
			alg: "HS256",
			payload: {
				exp: Math.floor(Date.now() / 1000) + 60 * 60
			}
		}
	};

	it("should be equals", done => {
		sign(symbol)
			.call(obj, {
				sub: "userID"
			})
			.then(token => {
				verify(symbol)
					.call(obj, token)
					.then(payload => {
						payload.should.has.property("sub");
						payload.sub.should.equal("userID");
						done();
					});
			});
	});
});
